{include file="public/layout"/}
<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit;min-width: auto;">
<style>
    body{margin:0px;}
    body,th,td{font: 13px Arial,Tahoma;line-height: 16px;}
    .alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#fff;padding:10px 10px 10px 5px;border-right: 1px solid #ddd;}
    .alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#fff;padding:10px 10px 10px 5px;border-right: 1px solid #ddd;vertical-align: middle;}
    .focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#F4FCFA;padding:10px 10px 10px 5px;border-right: 1px solid #ddd;}
    .head th{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:10px 10px 10px 5px;font-weight:bold;}
    .head th span{font-weight:normal;}
</style>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="flexigrid">
        <!-- 操作说明 -->
        <div id="explanation" class="explanation" style="color: rgb(44, 188, 163); background-color: rgb(237, 251, 248); width: 99%; height: 100%; margin-bottom: 10px;">
            <div id="checkZoom" class="title"><i class="fa fa-lightbulb-o"></i>
                <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
                <span title="收起提示" id="explanationZoom" style="display: block;"></span>
            </div>
            <ul>
                <li>采用360安全卫士提供的扫描技术</li>
                <li>扫描网站是否存在DOS攻击脚本php文件、可疑恶意木马文件等</li>
                <li>默认不扫描图片目录，可安装【易优系统助手】插件单独扫码图片</li>
            </ul>
        </div>
        <div style="margin:0px auto;border: 1px solid #ccc;">
            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tbody>
                    <tr class="head">
                        <th><img src="__SKIN__/images/360_logo.png?v={$version|default='v1.0.0'}" title="360网站卫士" border="0"></th>
                    </tr>
                </tbody>
            </table>
            <br>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tbody>
                    <tr>
                        <th style="vertical-align:middle; padding-left:5px;">网站存放路径：
                            {$root_path}
                            <input type="hidden" name="path" id="path" value="{$root_path}">
                            &nbsp;&nbsp;
                            <a href="javascript:void(0);" class="ncap-btn ncap-btn-green" onclick="scan();">开始扫描</a>
                        </th>
                    </tr>
                </tbody>
            </table>
            <br>
            <div id="div_scanlist" style="display: ;">
                <div style="padding:10px; background-color:#F4F4F4">扫描：<span id="span_scanned">0</span>&nbsp;文件&nbsp;&nbsp;|&nbsp;&nbsp;发现：<span id="span_count">0</span>&nbsp;行可疑恶意代码&nbsp;&nbsp;|&nbsp;&nbsp;耗时：<span id="span_spent">0</span>&nbsp;&nbsp;|&nbsp;&nbsp;请管理员手动处理以下可疑恶意文件</div>
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <thead>
                        <tr class="head">
                            <th width="30" style="text-align: center;">No.</th>
                            <th>可疑恶意文件</th>
                            <th width="100">所在行号</th>
                            <th width="500">详细代码片段</th>
                            <th width="30">操作</th>
                        </tr>
                    </thead>
                    <tbody id="tr_scan_html">
                        <tr>
                            <td class="no-data" style="width: auto !important;" align="center" axis="col0" colspan="5">
                                <i class="fa fa-exclamation-circle"></i>请点击<a href="javascript:void(0);" onclick="scan();">开始扫描</a>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <center>
                    <div style="margin: 20px 0px;">
                        此功能参考 <a href="http://wangzhan.360.cn" target="_blank">360网站卫士</a> 提供的DOS攻击脚本专杀工具，扫描结果仅供排查<br><br>Copyright ©2005-2022 360.cn 版权所有 360 互联网中心
                    </div>
                </center>
            </div>
        </div>
    </div>
</div>
<script>
    // scan();
    function scan()
    {
        var timer = '';
        var loading = layer.msg(
'<span id="progress_speed">准备扫描</span>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请勿刷新页面', 
        {
            time: 3600000, //1小时后后自动关闭
            shade: [0.2] //0.1透明度的白色背景
        });
        //loading层
        var index = layer.load(2, {
            shade: [0.1,'#fff'] //0.1透明度的白色背景
        });
        $.ajax({
            type: "POST",
            url: "{:url('Security/ddos_scan')}",
            data: {_ajax:1},
            dataType: 'json',
            beforeSend: function(xhr) {
                var html = '';
                html += '<tr>';
                html += '    <td class="no-data" style="width: auto !important;" align="center" axis="col0" colspan="5">';
                html += '        <i class="fa fa-exclamation-circle"></i>正在扫描中';
                html += '    </td>';
                html += '</tr>';
                $('#tr_scan_html').html(html);
                $('#div_scanlist').show();
                progressd(0);
            },
            success: function (res) {
                if(res.code == 1){
                    $('#progress_speed').html('已扫描<font id="progress_num">100</font>%');
                    setTimeout(function(){
                        layer.closeAll();
                        $('#span_scanned').html(res.data.scanned);
                        $('#span_count').html(res.data.num_ky);
                        $('#span_spent').html(res.data.spent);
                        $('#tr_scan_html').html(res.data.html);
                        showErrorAlert(res.msg, 6);
                    },1000);
                }else{
                    layer.closeAll();
                    showErrorAlert(res.msg);
                }
            },
            error:function(e){
                layer.closeAll();
                showErrorAlert(e.responseText);
            }
        });
    }

    function progressd(init)
    {
        $.ajax({
            type: "POST",
            url: "{:url('Security/ddos_progressd')}",
            data: {init:init, _ajax:1},
            dataType: 'json',
            success: function (res) {
                if(res.code == 1){
                    if (res.data.progress > 0) {
                        $('#span_scanned').html(res.data.file_num);
                        $('#span_count').html(res.data.file_num_ky);
                        $('#span_spent').html('计时中');
                        $('#tr_scan_html').html(res.data.html);
                        $('#div_scanlist').show();
                        var progress_num = $('#progress_num').val();
                        if (res.data.progress > progress_num || progress_num == undefined) {
                            $('#progress_speed').html('已扫描<font id="progress_num">' + res.data.progress + '</font>%');
                        }
                    }
                    if (100 > res.data.progress) {
                        progressd(1);
                    }
                }
            }
        });
    }

    function delfile(obj)
    {
        title = '确认删除？';
        btn = ['确定', '取消']; //按钮
        layer.confirm(title, {
            shade: layer_shade,
            area: ['480px', '190px'],
            move: false,
            title: '提示',
            btnAlign:'r',
            closeBtn: 3,
            btn: btn, //按钮
            success: function () {
                  $(".layui-layer-content").css('text-align', 'left');
              }
            }, function(){
                // 确定
                layer_loading('正在处理');
                var md5key = $(obj).attr('data-md5key');
                $.ajax({
                    type : 'POST',
                    url : "{:url('Security/ddos_delfile')}",
                    data : {md5key:md5key, _ajax:1},
                    dataType : 'json',
                    success : function(res){
                        layer.closeAll();
                        if(res.code == 1){
                            $('#tr_scan_html').find('a[data-md5key='+md5key+']').each(function(index, item){
                                $(item).parent().parent().remove();
                            });
                            if ($('#tr_scan_html tr').length == 0) {
                                var html = '';
                                html += '<tr>';
                                html += '    <td class="no-data" style="width: auto !important;" align="center" axis="col0" colspan="5">';
                                html += '        <i class="fa fa-exclamation-circle"></i>没有发现可疑文件';
                                html += '    </td>';
                                html += '</tr>';
                                $('#tr_scan_html').html(html);
                            }
                            layer.msg(res.msg, {icon: 1, time: 500});
                        }else{
                            showErrorAlert(res.msg);
                        }
                    },
                    error:function(e){
                        layer.closeAll();
                        showErrorAlert(e.responseText);
                    }
                })
            }, function(index){
                layer.close(index);
                return false;// 取消
            }
        );
    }
</script>
{include file="public/footer" /}